package com.company.bookstore.entities.cart_module;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.company.bookstore.entities.book_module.Book;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author 江洪锦
 * @since 2020-09-18
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_cart")
public class Cart extends Model<Cart> implements Serializable{

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * #用户id
     */
    private Integer userId;
    /**
     * #图书id
     */
    private Integer bookId;
    /**
     * #图书封面url
     */
    @TableField(exist = false)
    private Book book;
    /**
     * #图书金额
     */
    @TableField(exist = false)
    private Double price = 0.0;
    /**
     * #图书购买数量（限制3本）
     */
    private Integer num;
    /**
     * #图书购买总金额
     */
    @TableField(exist = false)
    private Double totalMoney = 0.0;
    /**
     * #是否选中，这个字段只是前端需要，后端无论何时都设置成
0就行！！！！！
     */
    private Integer selected;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
